/*!
   \file

   © 2011 Mark W. Gabby II

   This file is part of the Avion engine.

   The Avion engine is free software: you can redistribute it and/or modify it under the terms of
   the GNU General Public License as published by the Free Software Foundation, either version 3 of
   the License, or (at your option) any later version.

   The Avion engine is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
   without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See
   the GNU General Public License for more details.

   You should have received a copy of the GNU General Public License along with the Avion Engine.
   If not, see <http://www.gnu.org/licenses/>.
*/
#pragma once

#include "Math/AABB.hpp"
#include "Math/Matrix4x4.hpp"

#include "Components/gcBase.hpp"

class ModelData;

/*!
   \brief
      gcModel is a component that represents a model. Its functions contain all model-drawing code.
*/
class gcModel : public gcBase
{
public:
   gcModel( Entity * Owner );

   bool Init( const char * const ModelName,
              const Point3 & PosOffset = Point3( 0.0 ),
              const Quaternion<> & OrientationOffset = Quaternion<>(),
              const Point3 & ScaleOffset = Point3( 1.0f, 1.0f, 1.0f ) );

   AABB<3> GetWorldSpaceAABB();
   AABB<2> GetScreenSpaceAABB();

   bool Draw();
private:
   Matrix GetLocalToWorldMatrix();

   /*!
       \brief
           This function sets up a model as the current thing to be drawn.

       \param Handle
           A handle to the model.

       \return
           Returns a pointer to an array of indices used to draw the model.
   */
   void SetupModel( ModelData * Model );
   void DrawModel( ModelData * Model );

   uint32_t RegisterConcreteClassWithSystem();

   // A handle to the model drawn for this component in the resource manager
   // NOT the model component's handle
   uint32_t modelHandle;
   AABB<3> modelLocalAABB;
};
